<?php
	session_start();

	include("includes/connect.php");
	include("includes/function.php");

	$lvl_id		= $_SESSION["lvl_id"];
	$_SESSION["lvl1_id"] = substr($lvl_id, 0, 2); 
	$db = new myDBS;
	$db->selectDB("hr_udoncity");
	
	switch (strlen($lvl_id)) {
		case 2:

			$where = "lvl1_id = '$lvl_id'";
			$result = $db->showData1("lvl1", $where);
			$rows = $db->fetch_object ( $result );

			$lvl1 = $rows->lvl1_name;

			break;
		case 4:
			$temp_lvl = substr($lvl_id, 0, 2);
			$where = "lvl1_id = '$temp_lvl'";
			$result = $db->showData1("lvl1", $where);
			$rows = $db->fetch_object ( $result );

			$lvl1 = $rows->lvl1_name;

			$where = "lvl2_id = '$lvl_id'";
			$result = $db->showData1("lvl2", $where);
			$rows = $db->fetch_object ( $result );

			$lvl2 = $rows->lvl2_name;

			break;
		case 6:
			$temp_lvl = substr($lvl_id, 0, 2);
			$where = "lvl1_id = '$temp_lvl'";
			$result = $db->showData1("lvl1", $where);
			$rows = $db->fetch_object ( $result );

			$lvl1 = $rows->lvl1_name;

			$temp_lvl = substr($lvl_id, 0, 4);
			$where = "lvl2_id = '$temp_lvl'";
			$result = $db->showData1("lvl2", $where);
			$rows = $db->fetch_object ( $result );
			
			$lvl2 = $rows->lvl2_name;

			$temp_lvl = substr($lvl_id, 0, 6);
			$where = "lvl3_id = '$temp_lvl'";
			$result = $db->showData1("lvl3", $where);
			$rows = $db->fetch_object ( $result );

			$lvl3 = $rows->lvl3_name;

			break;
		case 8:
			$temp_lvl = substr($lvl_id, 0, 2);
			$where = "lvl1_id = '$temp_lvl'";
			$result = $db->showData1("lvl1", $where);
			$rows = $db->fetch_object ( $result );

			$lvl1 = $rows->lvl1_name;

			$temp_lvl = substr($lvl_id, 0, 4);
			$where = "lvl2_id = '$temp_lvl'";
			$result = $db->showData1("lvl2", $where);
			$rows = $db->fetch_object ( $result );

			$lvl2 = $rows->lvl2_name;

			$temp_lvl = substr($lvl_id, 0, 6);
			$where = "lvl3_id = '$temp_lvl'";
			$result = $db->showData1("lvl3", $where);
			$rows = $db->fetch_object ( $result );

			$lvl3 = $rows->lvl3_name;
			
			$temp_lvl = substr($lvl_id, 0, 8);
			$where = "lvl4_id = '$temp_lvl'";
			$result = $db->showData1("lvl4", $where);
			$rows = $db->fetch_object ( $result );

			$lvl4 = $rows->lvl4_name;

			break;
	}	

	$_SESSION["lvl1"]	= (is_null($lvl1))? "": $lvl1;
	$_SESSION["lvl2"]	= (is_null($lvl2))? "": $lvl2;
	$_SESSION["lvl3"]	= (is_null($lvl3))? "": $lvl3;
	$_SESSION["lvl4"]	= (is_null($lvl4))? "": $lvl4;

	$_SESSION["lvlfull"]	= $_SESSION["lvl1"] ." ". $_SESSION["lvl2"] ." ". $_SESSION["lvl3"] ." ". $_SESSION["lvl4"];

?>